import {
  UserInfo, UserLoginForm, UserLoginRes, UserMenuRes,
} from '@/types/user';
import request from '@/utils/request';

const api = {
  Login: '/auth/login',
  Logout: '/auth/logout',
  // get my info
  UserMenu: '/auth/menutree',
  UserInfo: '/auth/userinfo',
};

export function reqLogin(data: UserLoginForm) {
  return request<UserLoginRes>({
    url: api.Login,
    method: 'post',
    data,
  });
}

export function reqInfo() {
  return request<UserInfo>({
    url: api.UserInfo,
    method: 'post',
    isOthers: false, // 此属性设置请求第三方接口，不自动添加 baseURL
  });
}

export function reqMenu() {
  return request<UserMenuRes[]>({
    url: api.UserMenu,
    method: 'post',
  });
}

export function reqLogout() {
  return request({
    url: api.Logout,
    method: 'post',
  });
}
